/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainGame.java
 *
 * Created on May 14, 2011, 7:53:13 PM
 */
package myheartsgame;

import java.awt.*;
import java.awt.event.KeyEvent;
import java.util.*;
import java.util.ArrayList;
import javax.swing.*;

/**
 *
 * @author KaKa
 */
public class MainGame extends javax.swing.JFrame {

    /* Variable game*/
    static MainPanel _mainPanel;    
    // Dung lop _timer cua util, ko phai la cua swing
    java.util.Timer _timer;
    int _speedInGame = 10;
    public static ArrayList<Card> _MyCards;
    public static ArrayList<Card> _DealingCards;

    /*
     * Khoi tao cac bien toan cuc
     */
    private void InitGlobalClass() {
        // Vi tri bat dau cua cac nguoi choi
        GlobalClass.MyCards = new Point(300, GlobalClass.ScreenHeight - 150);
        GlobalClass.LeftCards = new Point(200, 50);
        GlobalClass.RightCards = new Point(GlobalClass.ScreenWidth - 150, 50);
        GlobalClass.AboveCards = new Point(430, 50);

    }

    /* Khoi tao panel chinh trong game
     * 
     */
    private void InitPanel() {

        _mainPanel = new MainPanel();
        setContentPane(_mainPanel);
        _mainPanel.setDoubleBuffered(true);
    }

    /*
     * Khoi tao bai cua chinh' nguoi choi
     */
    public static void InitPlayerCards(ArrayList<String> _cardsInfos) {

        if (_cardsInfos == null) {
            return;
        }

        for (int iCount = 0; iCount < 13; iCount++) {
            _MyCards.add(new Card(_cardsInfos.get(iCount)));
            // Ban dau thi an may la bai di
            _MyCards.get(iCount).setVisible(false);
            _MyCards.get(iCount).setLocation(GlobalClass.MyCards.x + iCount * _MyCards.get(0)._Width * 1/2,
                    GlobalClass.MyCards.y);
        }

        for (int iCount = 12; iCount >= 0; iCount--) {
            _mainPanel.add(_MyCards.get(iCount));
        }

    }

    /*
     * Sap xep lai bai
     */
    public void ArrangeCards() {

        for (int iCount = 0; iCount < 12; iCount++) {
            for (int iCheck = iCount + 1; iCheck < 13; iCheck++) {
                //if(_MyCards.get(iCount).getSuit() )
            }
        }
    }

    // Bat dau chia bai, se khoi tao 52 la
    void initDealCards() {
        _DealingCards = new ArrayList<Card>();
        for (int iCount = 0; iCount < 52; iCount++) {
            Card temp = new Card("0_0");
            temp.setLocation(GlobalClass.ScreenWidth / 2 - temp._Width,
                    GlobalClass.ScreenHeight / 2 - temp._Height);
            // Khong cho select vao cac la bai nay
            temp.setSelected(false);
            _DealingCards.add(temp);
        }

        for (int iCount = 51; iCount >= 0; iCount--) {
            _mainPanel.add(_DealingCards.get(iCount));
        }
    }
    // Bien dem de chia bai
    static int DealCounting = 0;
    // Mang luu chi so cac con bai cua minh trong bo bai
    static ArrayList<Integer> indexInAll = new ArrayList<Integer>();

    /*
     * Xu ly qua trinh chia bai
     */
    public static void Dealing() {

        if (DealCounting > 51) {
            // update cho het' la bai cuoi cung thi moi dung
            if (_DealingCards.get(51)._isMoving) {
                _DealingCards.get(51).Update();
            } else {

                // An^~ cac la' ba`i tam. luc chia
                // Hien cac la bai cua minh len
                for(int iCount = 0; iCount < 13; iCount++) {                    
                    _DealingCards.get(indexInAll.get(iCount)).setVisible(false);
                    _MyCards.get(iCount).setVisible(true);
                }
                // Da chia xong
                GlobalClass.isDealing = false;
                // Lat bai cua minh len
                GlobalClass.isOpeing = true;
            }

            // Khi DealCouting == 52
            // thi chi update chu ko xu ly nua.
            return;
        }

        if (DealCounting == 0) {
            _DealingCards.get(DealCounting).SetDestinationMove(GlobalClass.LeftCards.x,
                    GlobalClass.LeftCards.y);
            DealCounting++;
        } else {
            // Update cai truoc do
            _DealingCards.get(DealCounting - 1).Update();
            // Neu da chia xong la truoc thi chia tiep la sau
            if (!_DealingCards.get(DealCounting - 1)._isMoving) {

                int check = DealCounting % 4;
                int scale = DealCounting / 4;
                Point desLocation = new Point();
                // Chia lan luot tu ben trai va theo chieu kim dong ho
                switch (check) {
                    case 0:
                        desLocation = (Point) GlobalClass.LeftCards.clone();
                        break;
                    case 1:
                        desLocation = (Point) GlobalClass.AboveCards.clone();
                        desLocation.x = desLocation.x + scale * _DealingCards.get(0)._Width * 1 / 4;
                        break;
                    case 2:
                        desLocation = (Point) GlobalClass.RightCards.clone();
                        break;
                    case 3:
                        indexInAll.add(DealCounting);
                        desLocation = (Point) GlobalClass.MyCards.clone();
                        desLocation.x = desLocation.x + scale * _DealingCards.get(0)._Width * 1 / 2;
                        break;
                }

                if (check == 0 || check == 2) {
                    desLocation.y = desLocation.y + scale * _DealingCards.get(0)._Height * 1 / 4;
                }

                _DealingCards.get(DealCounting).SetDestinationMove(desLocation.x,
                        desLocation.y);
                DealCounting++;
            }
        }
    }

    int openingCount = 0;
    // Mo bai cua minh len
    private void OpeningMyCards() {

        if (openingCount > 12) {
            // Lat la bai cuoi cung
            if (_MyCards.get(openingCount - 1)._isOpening) {
                _MyCards.get(openingCount - 1).Update();
            } else {
                GlobalClass.isOpeing = false;
            }

            return;
        }

        if (openingCount == 0) {
            _MyCards.get(openingCount)._isOpening = true;
            openingCount++;
        } else {

            _MyCards.get(openingCount - 1).Update();
            // Neu la bai o truoc mo xong roi thimoi mo tiep
            if (!_MyCards.get(openingCount - 1)._isOpening) {
                _MyCards.get(openingCount)._isOpening = true;
                openingCount++;
            }
        }
         
        /*
        if (openingCount > 12) {
            // Lat la bai cuoi cung
            if (_DealingCards.get(indexInAll.get(openingCount - 1))._isOpening) {
                _DealingCards.get(indexInAll.get(openingCount - 1)).Update();
            } else {
                GlobalClass.isOpeing = false;
            }

            return;
        }

        if (openingCount == 0) {
            _DealingCards.get(indexInAll.get(openingCount))._isOpening = true;
            openingCount++;
        } else {

            _DealingCards.get(indexInAll.get(openingCount - 1)).Update();
            // Neu la bai o truoc mo xong roi thimoi mo tiep
            if (!_DealingCards.get(indexInAll.get(openingCount - 1))._isOpening) {
                _DealingCards.get(indexInAll.get(openingCount))._isOpening = true;
                openingCount++;
            }
        }

         */
    }

    /** Creates new form MainGame */
    public MainGame() {

        InitPanel();
        InitGlobalClass();
        setTitle("My hearts game - Network");
        initComponents();
        
        taChatBox.setLineWrap(true);
        _MyCards = new ArrayList<Card>();
        // Tao vong lap game
        _timer = new java.util.Timer();
        // Tao ket noi vong lap trong game, _speedInGame la thoi gian lap
        // delay = 100 la thoi gian cho` de thuc hien task
        _timer.schedule(new GameLoop(), 100, _speedInGame);

        // Khoi tao bai de chia
        initDealCards();
    }

    class GameLoop extends TimerTask {

        public void run() {
            if (GlobalClass.isDealing) {
                Dealing();
            }

            if (GlobalClass.isOpeing) {
                OpeningMyCards();
            }

            for (int iCount = 0; iCount < _MyCards.size(); iCount++) {
                _MyCards.get(iCount).Update();
            }

            _mainPanel.repaint();
        }
    }

    public void exitGame() {
        if (JOptionPane.showConfirmDialog(this, "Do you want to quit this game?") == JOptionPane.YES_OPTION) {
            dispose();
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btExit = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        taChatBox = new javax.swing.JTextArea();
        btSend = new javax.swing.JButton();
        tfChatting = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        lbAccount = new javax.swing.JLabel();
        lbPlayer2 = new javax.swing.JLabel();
        lbPlayer3 = new javax.swing.JLabel();
        lbPlayer4 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        miConnect = new javax.swing.JMenuItem();
        miCreate = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JPopupMenu.Separator();
        miNewGame = new javax.swing.JMenuItem();
        jSeparator3 = new javax.swing.JPopupMenu.Separator();
        miStatistics = new javax.swing.JMenuItem();
        miOptions = new javax.swing.JMenuItem();
        miChangeApp = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        miExit = new javax.swing.JMenuItem();
        mnHelp = new javax.swing.JMenu();
        mnAbout = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setIconImages(null);

        btExit.setText("Exit game");
        btExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btExitActionPerformed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel1.setOpaque(false);

        taChatBox.setColumns(20);
        taChatBox.setEditable(false);
        taChatBox.setRows(5);
        taChatBox.setAutoscrolls(false);
        taChatBox.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        taChatBox.setOpaque(false);
        jScrollPane1.setViewportView(taChatBox);

        btSend.setText("Send");
        btSend.setSelected(true);
        btSend.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSendActionPerformed(evt);
            }
        });

        tfChatting.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        tfChatting.setDisabledTextColor(new java.awt.Color(51, 255, 51));
        tfChatting.setOpaque(false);
        tfChatting.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tfChattingKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(tfChatting, javax.swing.GroupLayout.DEFAULT_SIZE, 158, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btSend))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 221, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE)
                .addGap(11, 11, 11)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tfChatting, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btSend))
                .addContainerGap())
        );

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel1.setForeground(new java.awt.Color(255, 0, 0));
        jLabel1.setText("Account:");

        lbAccount.setForeground(new java.awt.Color(255, 0, 0));
        lbAccount.setText("None");

        lbPlayer2.setForeground(new java.awt.Color(255, 0, 0));
        lbPlayer2.setText("Player 2");

        lbPlayer3.setForeground(new java.awt.Color(255, 0, 0));
        lbPlayer3.setText("Player 3");

        lbPlayer4.setForeground(new java.awt.Color(255, 0, 0));
        lbPlayer4.setText("Player 4");

        jMenu1.setText("Menu");

        miConnect.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK));
        miConnect.setText("Connect to server");
        miConnect.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miConnectActionPerformed(evt);
            }
        });
        jMenu1.add(miConnect);

        miCreate.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK));
        miCreate.setText("Create new server");
        miCreate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miCreateActionPerformed(evt);
            }
        });
        jMenu1.add(miCreate);
        jMenu1.add(jSeparator2);

        miNewGame.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_G, java.awt.event.InputEvent.CTRL_MASK));
        miNewGame.setText("New Game");
        jMenu1.add(miNewGame);
        jMenu1.add(jSeparator3);

        miStatistics.setText("Statistics");
        jMenu1.add(miStatistics);

        miOptions.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
        miOptions.setText("Options");
        miOptions.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                miOptionsMouseClicked(evt);
            }
        });
        miOptions.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miOptionsActionPerformed(evt);
            }
        });
        jMenu1.add(miOptions);

        miChangeApp.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK));
        miChangeApp.setText("Change Appearance");
        jMenu1.add(miChangeApp);
        jMenu1.add(jSeparator1);

        miExit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_MASK));
        miExit.setText("Exit");
        miExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miExitActionPerformed(evt);
            }
        });
        jMenu1.add(miExit);

        jMenuBar1.add(jMenu1);

        mnHelp.setText("Help");
        jMenuBar1.add(mnHelp);

        mnAbout.setText("About");
        jMenuBar1.add(mnAbout);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(108, 108, 108)
                        .addComponent(lbPlayer2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 794, Short.MAX_VALUE)
                        .addComponent(lbPlayer4))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(296, 296, 296)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lbAccount)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 276, Short.MAX_VALUE)
                                .addComponent(btExit))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(lbPlayer3)
                                .addGap(402, 402, 402)))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(182, 182, 182)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lbPlayer4, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lbPlayer2)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addComponent(lbPlayer3)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 250, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(btExit)
                        .addComponent(jLabel1)
                        .addComponent(lbAccount)))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btExitActionPerformed
        // TODO add your handling code here:
        exitGame();
    }//GEN-LAST:event_btExitActionPerformed

    private void miExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miExitActionPerformed
        // TODO add your handling code here:
        exitGame();
    }//GEN-LAST:event_miExitActionPerformed

    private void miCreateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miCreateActionPerformed

        if (GlobalClass.myClient != null) {
            int resultComfirm = JOptionPane.showConfirmDialog(this,
                    "You're a client who connect to a server. \n Do you want to quit?");
            if (resultComfirm == JOptionPane.YES_OPTION) {
                GlobalClass.myClient = null;
            } else {
                return;
            }
        }

        if (GlobalClass.myServer != null) {
            JOptionPane.showMessageDialog(this,
                    "You're a server now !!!", "Can not create",
                    JOptionPane.WARNING_MESSAGE);
            return;
        }

        try {
            GlobalClass.myServer = new Server();            
            
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this,
                    "Can not create a server! \n" + ex.toString(),
                    "Failed.", JOptionPane.ERROR_MESSAGE);
            return;
        }

        JOptionPane.showMessageDialog(this,
                "Created a server!",
                "Successfull.", JOptionPane.INFORMATION_MESSAGE);

        lbAccount.setText("Server.");
        GlobalClass.chatBox = "";
        RefreshChatBox();
    }//GEN-LAST:event_miCreateActionPerformed

    private void miConnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miConnectActionPerformed

        if (GlobalClass.myServer != null) {
            int resultComfirm = JOptionPane.showConfirmDialog(this,
                    "You are a server now!!! \n do you want to quit?");
            if (resultComfirm == JOptionPane.YES_OPTION) {
                GlobalClass.myServer = null;
            } else {
                return;
            }
        }

        if (GlobalClass.myClient != null) {
            int resultComfirm = JOptionPane.showConfirmDialog(this,
                    "You connected to a server!!! \n do you want to try another server?");
            if (resultComfirm == JOptionPane.YES_OPTION) {
                GlobalClass.myClient = null;
            } else {
                return;
            }
        }

        JDialog connectFrom = new ConnectToServer(this, false);
        connectFrom.setLocationRelativeTo(this);
        connectFrom.setVisible(true);

    }//GEN-LAST:event_miConnectActionPerformed

    public static void RefreshChatBox() {
        taChatBox.setText(GlobalClass.chatBox);
    }
    private String textBox = "";

    private void EnterChatHandle() {
        String strChat = tfChatting.getText().trim();
        if (strChat.length() > 0) {
            textBox += "Me: " + strChat + "\n";
            tfChatting.setText("");
            GlobalClass.chatBox += textBox;
            textBox = "";
            RefreshChatBox();

            String messageSend = GlobalClass.myName + ": " + strChat;

            if (GlobalClass.myClient != null) {
                GlobalClass.myClient.SendMessage(messageSend);
            } else {
                GlobalClass.myServer.SendMessage(messageSend);
            }
        }
    }

    private void btSendActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSendActionPerformed
        EnterChatHandle();
    }//GEN-LAST:event_btSendActionPerformed

    private void tfChattingKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tfChattingKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            EnterChatHandle();
        }
    }//GEN-LAST:event_tfChattingKeyPressed

    private void miOptionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miOptionsActionPerformed
        // TODO add your handling code here:

    }//GEN-LAST:event_miOptionsActionPerformed

    private void miOptionsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_miOptionsMouseClicked
        // TODO add your handling code here:

    }//GEN-LAST:event_miOptionsMouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new MainGame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btExit;
    private javax.swing.JButton btSend;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JPopupMenu.Separator jSeparator2;
    private javax.swing.JPopupMenu.Separator jSeparator3;
    public static javax.swing.JLabel lbAccount;
    private javax.swing.JLabel lbPlayer2;
    private javax.swing.JLabel lbPlayer3;
    private javax.swing.JLabel lbPlayer4;
    private javax.swing.JMenuItem miChangeApp;
    private javax.swing.JMenuItem miConnect;
    private javax.swing.JMenuItem miCreate;
    private javax.swing.JMenuItem miExit;
    private javax.swing.JMenuItem miNewGame;
    private javax.swing.JMenuItem miOptions;
    private javax.swing.JMenuItem miStatistics;
    private javax.swing.JMenu mnAbout;
    private javax.swing.JMenu mnHelp;
    public static javax.swing.JTextArea taChatBox;
    private javax.swing.JTextField tfChatting;
    // End of variables declaration//GEN-END:variables
}
